package com.example.springboot2.controller;

import com.example.springboot2.event.DemoEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class HelloController {

    @Resource
    private ApplicationEventPublisher publisher;

    @GetMapping("/hello")
    public String hello() {
        publisher.publishEvent(new DemoEvent(this, "系统创建"));
        return "hello world";
    }
}
